package com.selfdriving.wl.activity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import com.selfdriving.BaseApplication;
import com.selfdriving.R;

public class AdTravel {
	/** 当前View **/
	View view;
	BaseApplication application;
	Context context;

	private Button btnNext;

	private Spinner sort_spinner;

	private Spinner age_spinner;

	private OnClickListener onClickListener;

	LayoutInflater inflater;

	public AdTravel(BaseApplication application, Context context,
			OnClickListener onClickListener) {
		inflater = LayoutInflater.from(context);
		view = inflater.inflate(R.layout.add_travel_test, null);
		this.application = application;
		this.context = context;
		this.onClickListener = onClickListener;
		initViews();
	}

	public void initViews() {
		btnNext = (Button) view.findViewById(R.id.btnNext);

		sort_spinner = (Spinner) view.findViewById(R.id.sort_spinner);

		age_spinner = (Spinner) view.findViewById(R.id.age_spinner);

		btnNext.setOnClickListener(onClickListener);

		String[] mItems = context.getResources().getStringArray(
				R.array.travel_sort);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
				android.R.layout.simple_spinner_item, mItems);
		ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(context,
				android.R.layout.simple_spinner_item, context.getResources()
						.getStringArray(R.array.age));
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		sort_spinner.setAdapter(adapter);
		age_spinner.setAdapter(adapter2);
	}

	public View getView() {
		return view;
	}

}
